import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:oral_cloud/config/app_config.dart';
import 'package:oral_cloud/config/resource_mananger.dart';
import 'package:oral_cloud/config/router_manger.dart';
import 'package:oral_cloud/generated/l10n.dart' as l10n;
import 'package:oral_cloud/config/constant.dart';
import 'package:oral_cloud/model/user.dart';
import 'package:oral_cloud/ui/page/patient/patient_details_page.dart';
import 'package:oral_cloud/ui/widget/global_widget.dart';
import 'package:oral_cloud/ui/widget/image.dart';
import 'package:oral_cloud/utils/string_utils.dart';
import 'package:oral_cloud/view_model/user_model.dart';

import '../photo_page.dart';

final double hSpace = ScreenUtil.getInstance().setWidth(10);
final double vSpace = ScreenUtil.getInstance().setHeight(20);

final double hSpaceOfPad = ScreenUtil.getInstance().setWidth(50);
final double vSpaceOfPad = ScreenUtil.getInstance().setHeight(14);

// ignore: must_be_immutable
class PersonPage extends StatelessWidget {
  UserModel userModel = UserModel();
  @override
  Widget build(BuildContext context) {
    User user = userModel.user;
    print("PersonPage--->user=$user");

    Widget body = AppConfig.isPad
        ? PersonOfPadPage(user, onPressed: () => _logout(context))
        : PersonOfPhonePage(
            user,
            onPressed: () => _logout(context),
          );
    return Scaffold(
      appBar: GlobalAppBar(
        l10n.S.of(context).person,
      ).appBar,
      body: SafeArea(
        child:body,
      ),
    );
  }

  _logout(BuildContext context) {
    FlutterDownloader.cancelAll();
    userModel.clearUser();
    Navigator.of(context)
        .pushNamedAndRemoveUntil(RouteName.login, (route) => false);
  }
}

class PersonBasicWidget extends StatelessWidget {
  final User user;

  PersonBasicWidget(this.user);
  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(
            left: ScreenUtil.getInstance().setWidth(42),
            top: ScreenUtil.getInstance().setHeight(42)),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          children: [
            Stack(
              alignment: Alignment.bottomRight,
              children: [
                ClipOval(
                  child: WrapperImage(
                    imageType: ImageType.normal,
                    url: user.avatar,
                    placeholder: user.sex == 1
                        ? 'male_default.png'
                        : 'female_default.png',
                    height: ScreenUtil.getInstance().setWidth(126),
                    width: ScreenUtil.getInstance().setWidth(126),
                  ),
                ),
                Image.asset(
                  ImageHelper.wrapAssets(
                      user.sex == 1 ? 'male.png' : 'female.png'),
                  width: ScreenUtil.getInstance().setWidth(40),
                  height: ScreenUtil.getInstance().setWidth(40),
                )
              ],
            ),
            Expanded(
              child: Padding(
                padding: EdgeInsets.only(
                    left: ScreenUtil.getInstance().setWidth(42),
                    bottom: ScreenUtil.getInstance().setWidth(34)),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisSize: MainAxisSize.max,
                      children: [
                        Text(
                          user.name,
                          style: TextStyle(
                            fontWeight: FontWeight.bold,
                            color: Color(MYColors.textHighlightColor),
                            fontSize: FontSize.fontSizeXL,
                          ),
                        ),
                        SizedBox(width: hSpace),
                        VDividerWidget(),
                        SizedBox(width: hSpace),
                        CertifiedWidget(user.status == 1),
                        SizedBox(width: hSpace),
                        VDividerWidget(),
                        SizedBox(width: hSpace),
                        NormalText(
                            '学历: ${StringUtils.formatNullStr(user.degree)}'),
                      ],
                    ),
                    SizedBox(height: ScreenUtil.getInstance().setHeight(28)),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisSize: MainAxisSize.max,
                      children: [
                        NormalText(
                            '出生日期: ${StringUtils.formatNullStr(user.birthDate)}'),
                        SizedBox(width: hSpace),
                        VDividerWidget(),
                        SizedBox(width: hSpace),
                        NormalText(
                            '联系电话: ${StringUtils.formatNullStr(user.phone)}'),
                      ],
                    ),
                    SizedBox(height: vSpace),
                    NormalText(
                        '联系地址: ${StringUtils.formatNullStr(user.address)}'),
                    SizedBox(height: vSpace),
                    NormalText('擅长专业: ${StringUtils.appendSkill(user.skills)}'),
                  ],
                ),
              ),
            ),
          ],
        ),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              width: 10,
              color: Color(0xffeef5f9),
            ),
          ),
        ));
  }
}

class CertifiedWidget extends StatelessWidget {
  final bool certified;
  CertifiedWidget(this.certified);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Image.asset(
          ImageHelper.wrapAssets(
              certified ? 'certified.png' : 'uncertified.png'),
          width: ScreenUtil.getInstance().setWidth(24),
          height: ScreenUtil.getInstance().setHeight(30),
        ),
        SizedBox(
          width: ScreenUtil.getInstance().setWidth(10),
        ),
        Text(
          certified ? '已认证' : '未认证',
          style: TextStyle(
            color: Color(certified
                ? MYColors.textCertifiedColor
                : MYColors.textNormalColor),
            fontSize: FontSize.fontSizeL,
          ),
        ),
      ],
    );
  }
}

class PersonCertificationWidget extends StatelessWidget {
  final User user;

  PersonCertificationWidget(this.user);
  @override
  Widget build(BuildContext context) {
    List<Widget> childrenImages = [];
    if (user.certificationInfo != null &&
        user.certificationInfo.credentialsImg != null &&
        user.certificationInfo.credentialsImg.isNotEmpty) {
      childrenImages.add(
        CertificateImage(
            user.certificationInfo.credentialsImg, '医师资格证书', 'credentialTag'),
      );
    }
    if (user.certificationInfo != null &&
        user.certificationInfo.practiceImg != null &&
        user.certificationInfo.practiceImg.isNotEmpty) {
      childrenImages.add(
        CertificateImage(
            user.certificationInfo.practiceImg, '医师执业证书', 'practiceTag'),
      );
    }
    if (user.certificationInfo != null &&
        user.certificationInfo.titleImg != null &&
        user.certificationInfo.titleImg.isNotEmpty) {
      childrenImages.add(
        CertificateImage(user.certificationInfo.titleImg, '职称证书', 'titleTag'),
      );
    }
    MainAxisAlignment mainAxisAlignment;
    if(childrenImages.length==3){
      mainAxisAlignment=MainAxisAlignment.spaceBetween;
    }else if(childrenImages.length==2) {
      mainAxisAlignment=MainAxisAlignment.start;
      childrenImages.insert(1, SizedBox(
        width: ScreenUtil.getInstance().setWidth(70),
      ));
    }else{
      mainAxisAlignment=MainAxisAlignment.start;
    }


    return Container(
      padding: EdgeInsets.symmetric(
          horizontal: ScreenUtil.getInstance().setWidth(42)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          UnderLineText(
            '医师认证信息',
            color: Colors.black,
            height: ScreenUtil.getInstance().setHeight(76),
          ),
          UnderLineText(
            '医师资格证书编号: ${StringUtils.formatNullStr(user.certificationInfo?.credentialsNo)}',
            height: ScreenUtil.getInstance().setHeight(100),
          ),
          UnderLineText(
            '医师执业证书编号: ${StringUtils.formatNullStr(user.certificationInfo?.practiceNo)}',
            height: ScreenUtil.getInstance().setHeight(100),
          ),
          UnderLineText(
            '执业医院: ${StringUtils.formatNullStr(user.hospital)}',
            height: ScreenUtil.getInstance().setHeight(100),
          ),
          UnderLineText(
            '职称: ${StringUtils.formatNullStr(user.title)}',
            height: ScreenUtil.getInstance().setHeight(100),
          ),
          SizedBox(
            height: ScreenUtil.getInstance().setHeight(22),
          ),
          NormalText('证件照片:'),
          SizedBox(
            height: ScreenUtil.getInstance().setHeight(34),
          ),
          Container(
            padding: EdgeInsets.symmetric(
                horizontal: ScreenUtil.getInstance().setWidth(98)),
            child: Row(
              mainAxisAlignment: mainAxisAlignment,
              children: childrenImages,
            ),
          ),
        ],
      ),
    );
  }
}

class CertificateImageType {
  static const int typeCredential = 0;
  static const int typePractice = 1;
  static const int typeTitle = 2;
}

typedef CertificateImageTabCallback = Function(int type);

// ignore: must_be_immutable
class CertificateImageOfPad extends StatelessWidget {
  CertificateImageTabCallback imageTab;
  final List<dynamic> imgUrls;
  final String title;
  final int imageType;
  CertificateImageOfPad(this.imgUrls, this.title,
      {this.imageTab, this.imageType: 0});
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        GestureDetector(
          onTap: () {
            print('GestureDetector--->onTap imageType=$imageType');
            imageTab(imageType);
          },
          child: WrapperImage(
            imageType: ImageType.normal,
            url: imgUrls[0],
            placeholder: 'certificate_default.png',
            height: ScreenUtil.getInstance().setHeight(156),
            width: ScreenUtil.getInstance().setHeight(220),
          ),
        ),
        SizedBox(
          height: vSpaceOfPad,
        ),
        NormalText(title),
      ],
    );
  }
}

class CertificateImage extends StatelessWidget {
  final List<dynamic> imgUrls;
  final String title;
  final String heroTag;
  CertificateImage(this.imgUrls, this.title, this.heroTag);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Column(
      children: [
        GestureDetector(
          onTap: () {
            Navigator.of(context).push(new FadeRoute(
                page: PhotoViewGalleryScreen(
              images: imgUrls, //传入图片list
              index: 0,
              heroTag: heroTag, //传入当前点击的图片的index
            )));
//            )));
          },
          child: Hero(
            tag: heroTag,
            child: WrapperImage(
              imageType: ImageType.normal,
              url: imgUrls[0],
              placeholder: 'certificate_default.png',
              height: ScreenUtil.getInstance().setWidth(220),
              width: ScreenUtil.getInstance().setWidth(220),
            ),
          ),
        ),
        SizedBox(
          height: vSpace,
        ),
        Text(
          title,
          style: TextStyle(
            color: Color(MYColors.textNormalColor),
            fontSize: FontSize.fontSizeL,
          ),
        )
      ],
    );
  }
}

class LogoutButtonWidget extends StatelessWidget {
  final Widget child;
  final VoidCallback onPressed;

  LogoutButtonWidget({this.child, this.onPressed});

  @override
  Widget build(BuildContext context) {
    var color = Theme.of(context).primaryColor;
    return Padding(
        padding: EdgeInsets.symmetric(
          horizontal: ScreenUtil.getInstance().setWidth(42),
        ),
        child: CupertinoButton(
          padding: EdgeInsets.all(0),
          color: color,
          disabledColor: color,
          borderRadius: BorderRadius.circular(3),
          pressedOpacity: 0.5,
          child: child,
          onPressed: onPressed,
        ));
  }
}

class VDividerWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 1,
      height: ScreenUtil.getInstance().setHeight(28),
      child: DecoratedBox(
        decoration: BoxDecoration(color: Color(MYColors.textNormalColor)),
      ),
    );
  }
}

class PersonOfPhonePage extends StatelessWidget {
  final User user;
  final VoidCallback onPressed;
  PersonOfPhonePage(this.user, {this.onPressed});
  @override
  Widget build(BuildContext context) {
    List<Widget> widgets = [
      PersonBasicWidget(user),
    ];
    widgets.add(
      PersonCertificationWidget(user),
    );
    widgets.add(Expanded(
      child: SizedBox(),
    ));
    widgets.add(
      CommonButtonWidget(
        width: ScreenUtil.getInstance().setWidth(800),
        height: ScreenUtil.getInstance().setHeight(AppConfig.inputHeight),
        child: Text(
          l10n.S.of(context).logout,
          style: TextStyle(color: Colors.white, fontSize: FontSize.fontSizeL),
        ),
        onPressed: onPressed,
      ),
    );
    widgets.add(SizedBox(height:ScreenUtil.getInstance().setHeight(42) ,));

    return Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: widgets,
      ),
    );
  }
}

class PersonOfPadPage extends StatefulWidget {
  final User user;
  final VoidCallback onPressed;

  PersonOfPadPage(this.user, {this.onPressed});
  @override
  State<StatefulWidget> createState() {
    return _PersonOfPadPageState();
  }
}

class _PersonOfPadPageState extends State<PersonOfPadPage> {
  int selectImageType;
  final GlobalKey<RightPhotoWidgetState> rightPhotoKey = GlobalKey();
  final GlobalKey<_CertificateTitleState> titleKey = GlobalKey();
  @override
  Widget build(BuildContext context) {
    List<Widget> children;
    List images = [];
    String title = '';
    if (widget.user.certificationInfo != null &&
        widget.user.certificationInfo.credentialsImg != null &&
        widget.user.certificationInfo.credentialsImg.isNotEmpty) {
      images = widget.user.certificationInfo.credentialsImg;
      title = "医师资格证书";
      selectImageType = CertificateImageType.typeCredential;
    } else if (widget.user.certificationInfo != null &&
        widget.user.certificationInfo.practiceImg != null &&
        widget.user.certificationInfo.practiceImg.isNotEmpty) {
      images = widget.user.certificationInfo.practiceImg;
      title = "医师执业证书";
      selectImageType = CertificateImageType.typePractice;
    } else if (widget.user.certificationInfo != null &&
        widget.user.certificationInfo.titleImg != null &&
        widget.user.certificationInfo.titleImg.isNotEmpty) {
      images = widget.user.certificationInfo.titleImg;
      title = "职称证书";
      selectImageType = CertificateImageType.typeTitle;
    }
    children = [
      Container(
        height: ScreenUtil.getInstance().setHeight(828),
        width: ScreenUtil.getInstance().setWidth(930),
        margin: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(60)),
        padding: EdgeInsets.only(
            left: ScreenUtil.getInstance().setWidth(18),
            right: ScreenUtil.getInstance().setWidth(18),
            top: ScreenUtil.getInstance().setHeight(82),
            bottom: ScreenUtil.getInstance().setHeight(20)),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(8)),
          color: Color(0XFFEDEFF2),
        ),
        child: RightPhotoWidget(
          key: rightPhotoKey,
          placeholderWidth: ScreenUtil.getInstance().setWidth(220),
          placeholderHeight: ScreenUtil.getInstance().setHeight(155),
          noDataHint: '暂无照片',
          placeholder: 'no_certicate_image.png',
          images: images,
          backgroudColor: Colors.transparent,
        ),
      ),
      SizedBox(
        height: ScreenUtil.getInstance().setHeight(28),
      ),
      CertificateTitle(titleKey, title),
    ];

    return Container(
      color: Color(0XFFF4F4F4),
      padding: EdgeInsets.only(
          left: ScreenUtil.getInstance().setWidth(99),
          right: ScreenUtil.getInstance().setWidth(99),
          top: ScreenUtil.getInstance().setHeight(40)),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Container(
            padding: EdgeInsets.symmetric(
              vertical: ScreenUtil.getInstance().setHeight(80),
            ),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(4)),
              color: Color(0XFFFFFFFF),
            ),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Expanded(
                  child: PersonLeftWidget(
                    widget.user,
                    imageTab: (type) {
                      print('PersonLeftWidget imageTab type=$type');
                      if (selectImageType == type) {
                        print(
                            'No need updateImages when selectImageType ==type');
                        return;
                      }
                      selectImageType = type;
                      String title = getTitleByImageType(selectImageType);
                      titleKey?.currentState?.updateTitle(title);
                      if (type == CertificateImageType.typeCredential) {
                        rightPhotoKey?.currentState?.updateImages(
                            widget.user.certificationInfo.credentialsImg, true);
                      } else if (type == CertificateImageType.typePractice) {
                        rightPhotoKey?.currentState?.updateImages(
                            widget.user.certificationInfo.practiceImg, true);
                      } else if (type == CertificateImageType.typeTitle) {
                        rightPhotoKey?.currentState?.updateImages(
                            widget.user.certificationInfo.titleImg, true);
                      }
                    },
                  ),
                ), //vertical: ScreenUtil.getInstance().setHeight(82),horizontal:ScreenUtil.getInstance().setWidth(18)),

                Column(
                  children: children,
                ),
              ],
            ),
          ),
          SizedBox(
            height: ScreenUtil.getInstance().setHeight(50),
          ),
          Container(
            width: ScreenUtil.getInstance().setWidth(582),
//            height: ScreenUtil.getInstance().setHeight(124),
            child: CommonButtonWidget(
              height: ScreenUtil.getInstance().setHeight(AppConfig.inputHeight),
              child: Text(
                l10n.S.of(context).logout,
                style: TextStyle(
                    color: Colors.white, fontSize: FontSize.fontSizeXL),
              ),
              onPressed: widget.onPressed,
            ),
          ),
        ],
      ),
    );
  }

  String getTitleByImageType(int selectImageType) {
    String title;
    if (selectImageType == CertificateImageType.typeCredential) {
      title = "医师资格证书";
    } else if (selectImageType == CertificateImageType.typePractice) {
      title = "医师执业证书";
    } else if (selectImageType == CertificateImageType.typeTitle) {
      title = "职称证书";
    }
    return title;
  }
}

class CertificateTitle extends StatefulWidget {
  String title;

  CertificateTitle(Key key, this.title) : super(key: key);
  @override
  State<StatefulWidget> createState() {
    return _CertificateTitleState();
  }
}

class _CertificateTitleState extends State<CertificateTitle> {
  updateTitle(String title) {
    setState(() {
      this.widget.title = title;
    });
  }

  @override
  Widget build(BuildContext context) {
    return NormalText(widget.title);
  }
}

class PersonLeftWidget extends StatelessWidget {
  final User user;
  final CertificateImageTabCallback imageTab;
  PersonLeftWidget(this.user, {this.imageTab});
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
          left: ScreenUtil.getInstance().setWidth(100),
          right: ScreenUtil.getInstance().setWidth(70)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          PersonBasicOfPadWidget(user),
          PersonCertificationOfPadWidget(user, imageTab: imageTab),
        ],
      ),
    );
  }
}

class PersonRightWidget extends StatelessWidget {
  final String title;
  PersonRightWidget(this.title);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Column(
      children: [
        Container(
          margin: EdgeInsets.only(
              top: ScreenUtil.getInstance().setHeight(82),
              bottom: ScreenUtil.getInstance().setHeight(28),
              right: ScreenUtil.getInstance().setWidth(60)),
          padding: EdgeInsets.symmetric(
              vertical: ScreenUtil.getInstance().setHeight(82),
              horizontal: ScreenUtil.getInstance().setWidth(18)),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.all(Radius.circular(8)),
            color: Color(0XFFEDEFF2),
          ),
          child: WrapperImage(
            imageType: ImageType.normal,
            url:
                'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597205080254&di=d1d25af08d9ee8d45b8dde5f565a68ba&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180724%2Fee6da4ad80a64e1e8f604e6b5bafc2f5.jpeg',
            placeholder: 'certificate_default.png',
            height: ScreenUtil.getInstance().setHeight(828),
            width: ScreenUtil.getInstance().setWidth(930),
          ),
        ),
//        SizedBox(
//          height: vSpaceOfPad,
//        ),
        NormalText(title),
        SizedBox(
          height: ScreenUtil.getInstance().setHeight(102),
        ),
      ],
    );
  }
}

class PersonBasicOfPadWidget extends StatelessWidget {
  final User user;

  PersonBasicOfPadWidget(this.user);
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: 1,
            color: Color(0xffE6E6E6),
          ),
        ),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Column(
            children: [
              Stack(
                alignment: Alignment.bottomRight,
                children: [
                  ClipOval(
                    child: WrapperImage(
                      imageType: ImageType.normal,
                      url: user.avatar,
                      placeholder: user.sex == 1
                          ? 'male_default.png'
                          : 'female_default.png',
                      height: ScreenUtil.getInstance().setWidth(126),
                      width: ScreenUtil.getInstance().setWidth(126),
                    ),
                  ),
                  Image.asset(
                    ImageHelper.wrapAssets(
                        user.sex == 1 ? 'male.png' : 'female.png'),
                    width: ScreenUtil.getInstance().setWidth(40),
                    height: ScreenUtil.getInstance().setWidth(40),
                  )
                ],
              ),
              SizedBox(height: vSpaceOfPad),
              CertifiedWidget(user.status == 1),
            ],
          ),
          SizedBox(
            width: ScreenUtil.getInstance().setWidth(30),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    NormalText('姓名: ${StringUtils.formatNullStr(user.name)}'),
//                  SizedBox(width: hSpaceOfPad),
                    NormalText('学历: ${StringUtils.formatNullStr(user.degree)}'),
//                  SizedBox(width: hSpaceOfPad),
                    NormalText(user.sex == 1 ? '性别：男' : '性别：女'),
                  ],
                ),
                SizedBox(height: vSpaceOfPad),
                NormalText(
                    '出生日期: ${StringUtils.formatNullStr(user.birthDate)}'),
                SizedBox(height: vSpaceOfPad),
                NormalText('联系电话: ${StringUtils.formatNullStr(user.phone)}'),
                SizedBox(height: vSpaceOfPad),
                NormalText('联系地址: ${StringUtils.formatNullStr(user.address)}'),
                SizedBox(height: vSpaceOfPad),
                NormalText('擅长专业: ${StringUtils.appendSkill(user.skills)}'),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

class PersonCertificationOfPadWidget extends StatelessWidget {
  final User user;

  final CertificateImageTabCallback imageTab;

  PersonCertificationOfPadWidget(this.user, {this.imageTab});
  @override
  Widget build(BuildContext context) {
    List<Widget> childrenImages = [];
    if (user.certificationInfo != null &&
        user.certificationInfo.credentialsImg != null &&
        user.certificationInfo.credentialsImg.isNotEmpty) {
      childrenImages.add(CertificateImageOfPad(
        user.certificationInfo.credentialsImg,
        '医师资格证书',
        imageTab: imageTab,
        imageType: CertificateImageType.typeCredential,
      ));
      childrenImages.add(SizedBox(
        width: ScreenUtil.getInstance().setWidth(10),
      ));
    }
    if (user.certificationInfo != null &&
        user.certificationInfo.practiceImg != null &&
        user.certificationInfo.practiceImg.isNotEmpty) {
      childrenImages.add(CertificateImageOfPad(
        user.certificationInfo.practiceImg,
        '医师执业证书',
        imageTab: imageTab,
        imageType: CertificateImageType.typePractice,
      ));
      childrenImages.add(SizedBox(
        width: ScreenUtil.getInstance().setWidth(10),
      ));
    }
    if (user.certificationInfo != null &&
        user.certificationInfo.titleImg != null &&
        user.certificationInfo.titleImg.isNotEmpty) {
      childrenImages.add(CertificateImageOfPad(
        user.certificationInfo.titleImg,
        '职称证书',
        imageTab: imageTab,
        imageType: CertificateImageType.typeTitle,
      ));
    }
    List<Widget> children;
    children = [
      Text(
        '医师认证信息',
        style: TextStyle(color: Colors.black, fontSize: FontSize.fontSizeL),
      ),
      SizedBox(
        height: ScreenUtil.getInstance().setHeight(30),
      ),
      NormalText(
        '医师资格证书编号: ${StringUtils.formatNullStr(user.certificationInfo?.credentialsNo)}',
      ),
      SizedBox(
        height: vSpaceOfPad,
      ),
      NormalText(
        '医师执业证书编号: ${StringUtils.formatNullStr(user.certificationInfo?.practiceNo)}',
      ),
      SizedBox(
        height: vSpaceOfPad,
      ),
      NormalText(
        '执业医院: ${StringUtils.formatNullStr(user.hospital)}',
      ),
      SizedBox(
        height: vSpaceOfPad,
      ),
      NormalText(
        '职称: ${StringUtils.formatNullStr(user.title)}',
      ),
      SizedBox(
        height: vSpaceOfPad,
      ),
      Text(
        '证件照片:',
        style: TextStyle(color: Colors.black, fontSize: FontSize.fontSizeL),
      ),
      SizedBox(
        height: 3 * vSpaceOfPad,
      ),
    ];

    if (childrenImages.isNotEmpty) {
      children.add(Container(
        padding: EdgeInsets.symmetric(
            horizontal: ScreenUtil.getInstance().setWidth(0)),
        child: Row(
          children: childrenImages,
        ),
      ));
    }

    return Container(
      padding: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(30)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: children,
      ),
    );
  }
}
